<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="box">
      <p>hello p1</p>
      <p>hello p2</p>
      <p>hello p3</p>
    </div>
    <div class="max">
      <p>hello p4</p>
      <p>hello p5</p>
    </div>
    <script>
      const elP = document.querySelectorAll("div p");
      console.log([...elP]);

      [...elP].forEach((el) => {
        console.log(el);
        el.style.backgroundColor = "yellow";
      });

      console.log(elP[0].matches("body p"));
      console.log(elP[0].matches(".box p"));
      console.log(elP[0].matches("p"));
      console.log(elP[0].matches(".max p"));
    </script>
  </body>
</html>
